package com.qiangesoft.weather.controller;

import com.qiangesoft.weather.gaode.entity.Weather;
import com.qiangesoft.weather.gaode.entity.WeatherForecast;
import com.qiangesoft.weather.gaode.service.IWeatherForecastService;
import com.qiangesoft.weather.gaode.service.IWeatherService;
import com.qiangesoft.weather.util.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 实时天气 前端控制器
 * </p>
 *
 * @author qiangesoft
 * @since 2023-08-10
 */
@RestController
@RequestMapping("/weather")
@Api(tags = "天气管理")
public class GaodeWeatherController {

    @Autowired
    private IWeatherService weatherService;
    @Autowired
    private IWeatherForecastService weatherForecastService;

    @ApiOperation("实时天气")
    @GetMapping("/live")
    public ResultInfo<Weather> liveWeather(String adcode) {
        return ResultInfo.ok(weatherService.liveWeather(adcode));
    }

    @ApiOperation("预报天气")
    @GetMapping("/forecast")
    public ResultInfo<List<WeatherForecast>> forecastWeather(String adcode) {
        return ResultInfo.ok(weatherForecastService.forecastWeather(adcode));
    }

}

